home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
United Public Domain Gold 4
/
United Public Domain Gold 4.iso
/
fredfish
/
ff.0773.dms
/
ff.0773.adf
/
REXXProgs
/
Sz.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1992-12-05
|
3KB
|
149 lines
/* Sz.rexx - a formatted, alphabetized dir + filesize display utility. */
/* Works best on a 68030, because its not real fast on a standard 68000. */
/* REQUIRES QuickSort, & the arp, rexxsupport, and rexarplib libraries. */
/* Supports wildcards (*, ?, or #?) */
/* copyright 1990 Richard Lee Stockton and Gramma Software. */
/* This code is FREELY DISTRIBUTABLE as long as this copyright */
/* notice remains, unchanged, at the start of the code. Thank you. */
/* Mount needed libraries if I can find 'em */
IF(~EXISTS("libs:rexxsupport.library")|~EXISTS("libs:rexxarplib.library")) THEN
DO
SAY "Couldn't find needed library (rexxsupport and/or rexxarplib)."
EXIT 20
END
CALL ADDLIB('rexxsupport.library',0,-30,0)
CALL ADDLIB('rexxarplib.library',0,-30,0)
/* Mount the QuickSort function if it's not up. (Thanks Marvin!) */
IF ~SHOWLIST('P','QuickSortPort') THEN
DO
ADDRESS COMMAND "run quicksort >NIL:"
DO i=1 TO 10
IF ~SHOWLIST('P','QuickSortPort') THEN CALL DELAY(20)
ELSE LEAVE i
END
IF ~SHOWLIST('P','QuickSortPort') THEN
DO
SAY "Unable to find QuickSortPort."
EXIT 20
END
END
CALL ADDLIB('QuickSortPort',-30)
/* get (or make) the file specification */
PARSE ARG spec .
IF spec="" THEN spec=PRAGMA("D")
IF POS("*",spec)=0 & POS("?",spec)=0 THEN
DO
test=RIGHT(spec,1)
IF test=":" | test="/" THEN spec=spec"*"
ELSE spec=spec"/*"
END
/* fetch the filelist */
files.=""
IF FileList(spec,files,,E)=0 THEN
DO
SAY "A directory of" spec "does not produce any names."
EXIT 10
END
/* get the fileinfo, fill in the stem parts, and keep running totals. */
/* I count the total FILE bytes including file headers, but ignoring */
/* drawer headers so I know how much disk-space the FILES will take. */
/* This is the part that gets rather slow on large directories.. */
longest=0
bytes=0
dirs=0
size.=""
DO i=1 TO files.0
info=STATEF(files.i)
indx=LASTPOS("/",files.i)
IF indx=0 THEN indx=LASTPOS(":",files.i)
files.i=SUBSTR(files.i,indx+1)
temp=files.i
size.temp=word(info,2)
test=LENGTH(files.i)
IF WORD(info,1)="FILE" THEN
DO
test=test+1+LENGTH(size.temp)
bytes=bytes+size.temp+512 /* 512=one block for fileheader */
END
ELSE
DO
size.temp=-1 /* allow for zero length files by making dir=-1 */
dirs=dirs+1
END
IF test>longest THEN longest=test
END
/* sort it */
call QSORT(1,files.0,files)
columns=77%(longest+1)
/* window pen color codes */
def = ""
pen1 = "
"
pen2 = "
"
pen3 = "
"
bak1 = "
"
bak2 = "
"
bak3 = "
"
/* seperate the files from the dirs */
DO i=1 TO files.0
temp=files.i
IF size.temp>=0 THEN
files.i=files.i RIGHT(size.temp,longest-length(files.i)-1)
ELSE files.i=pen3||LEFT(files.i,longest)||def
END
/* format the drawer string */
string=bak2 spec "="
IF files.0>dirs THEN
DO
string=string bytes "bytes in" files.0-dirs "files"
IF dirs>0 THEN string=string "+"
END
IF dirs>0 THEN string=string dirs "drawers"
SAY string def
/* format the lines */
lines=files.0%columns
IF files.0//columns>0 THEN lines=lines+1
DO i = 1 TO lines;
string=pen2"|"def||files.i||pen2"|"def
DO ii=1 TO columns-1
j=i+ii*lines
IF files.j~="" THEN string=string||files.j||pen2"|"def
END
SAY string
END
/* end of Sz.rexx | 16 October 1990 */